<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>

<body>
    <script id="test" type="text/html">
            <h1> <%= title %> </h1>
        <ul>
            <%for(value in list){%>
                <li>索引 <%=value%> ：<%:=list[value]%><%:=value%></li >
            <%
        } %>
            </ul>
    </script>
    <script src="xtpl.1.1.js"></script>
     <div id="result"></div>
    <script>
        var data = {
            title: '标签',
            list: ['文艺', '博客', '摄影', '电影', '民谣 <a href="#">aa</a>', '旅行', '吉他']
        };
         // console.log(xtpl);
        //var str = xtpl.render(document.getElementById("test").innerHTML, data);
        str = xtpl.compile(document.getElementById("test").innerHTML)(data);
        document.getElementById("result").innerHTML = str;
        console.log(str);
    </script>
  
</body>

</html>